#import "USSexChangeView.h"

@implementation USSexChangeView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self.btn0 addTarget:self action:@selector(btn0Tapped) forControlEvents:UIControlEventTouchUpInside];
    [self.btn1 addTarget:self action:@selector(btn1Tapped) forControlEvents:UIControlEventTouchUpInside];
    [self updateUIForSex:self.sex]; // 默认初始化
    
}

- (void)setSex:(USSexType)sex {
    _sex = sex;
    [self updateUIForSex:sex];
}

- (void)setSex:(USSexType)sex animated:(BOOL)animated {
    if (_sex == sex) return;
    _sex = sex;
    [self updateUIForSex:sex];
}

- (void)btn0Tapped {
    [USFeedbackTool selectionChanged];
    [self setSex:USSexTypeMale animated:YES];
}

- (void)btn1Tapped {
    [USFeedbackTool selectionChanged];
    [self setSex:USSexTypeFemale animated:YES];
}

- (void)updateUIForSex:(USSexType)sex {
    self.btn0.selected = (sex == USSexTypeMale);
    self.btn1.selected = (sex == USSexTypeFemale);
}

@end
